﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebAsp.DTO;

namespace WebAsp.DAL
{
    public class StudentDAL
    {
        public static List<string> GetImages(int StudentID)
        {
            LinQDataContext dt = new LinQDataContext();
            var query = from t in dt.IMAGEs
                        where t.StudentID == StudentID
                        select t.ImagesLink;
            return query.ToList();
        }

        public static List<StudentDTO> GetList()
        {
            LinQDataContext dt = new LinQDataContext();
            var query = from t in dt.STUDENTs
                        select new StudentDTO(t.StudentID, t.Name, t.Brithday, t.Summary, GetImages(t.StudentID));
            return query.ToList();
        }

        public static StudentDTO GetItem(int StudentID)
        {
            LinQDataContext dt = new LinQDataContext();
            var query = from t in dt.STUDENTs
                        where t.StudentID == StudentID
                        select new StudentDTO(t.StudentID, t.Name, t.Brithday, t.Summary, GetImages(t.StudentID));
            return query.FirstOrDefault();
        }
    }
}